package com.ruoyi.ies.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ies.domain.AllGstation;
import com.ruoyi.ies.service.IAllGstationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 所有垃圾站Controller
 * 
 * @author July
 * @date 2023-06-15
 */
@RestController
@RequestMapping("/ies/astation")
public class AllGstationController extends BaseController
{
    @Autowired
    private IAllGstationService allGstationService;

    /**
     * 查询所有垃圾站列表
     */
    @PreAuthorize("@ss.hasPermi('ies:astation:list')")
    @GetMapping("/list")
    public TableDataInfo list(AllGstation allGstation)
    {
        startPage();
        List<AllGstation> list = allGstationService.selectAllGstationList(allGstation);
        return getDataTable(list);
    }

    /**
     * 导出所有垃圾站列表
     */
    @PreAuthorize("@ss.hasPermi('ies:astation:export')")
    @Log(title = "所有垃圾站", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AllGstation allGstation)
    {
        List<AllGstation> list = allGstationService.selectAllGstationList(allGstation);
        ExcelUtil<AllGstation> util = new ExcelUtil<AllGstation>(AllGstation.class);
        util.exportExcel(response, list, "所有垃圾站数据");
    }

    /**
     * 获取所有垃圾站详细信息
     */
    @PreAuthorize("@ss.hasPermi('ies:astation:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(allGstationService.selectAllGstationById(id));
    }

    /**
     * 新增所有垃圾站
     */
    @PreAuthorize("@ss.hasPermi('ies:astation:add')")
    @Log(title = "所有垃圾站", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AllGstation allGstation)
    {
        return toAjax(allGstationService.insertAllGstation(allGstation));
    }

    /**
     * 修改所有垃圾站
     */
    @PreAuthorize("@ss.hasPermi('ies:astation:edit')")
    @Log(title = "所有垃圾站", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AllGstation allGstation)
    {
        return toAjax(allGstationService.updateAllGstation(allGstation));
    }

    /**
     * 删除所有垃圾站
     */
    @PreAuthorize("@ss.hasPermi('ies:astation:remove')")
    @Log(title = "所有垃圾站", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(allGstationService.deleteAllGstationByIds(ids));
    }
}
